package tools;

public class StringTestDriver {
    public static void main(String[] args) {
        /**
         * String类常用方法：indexof*/
        test01();
        System.out.println("=====================");
        test02();
    }
    private static void test01(){
        String str0="fajfjjfhkafhkf156416513";
        System.out.println("原始文本"+str0);
        System.out.println("a的位置"+str0.indexOf("a"));//传整数
        System.out.println("a的位置"+str0.indexOf("a", 2));
    }
    private static void test02(){
        String str0="fajfj,jfhkfhkf15,6416513";
        System.out.println("原始文本"+str0);
        System.out.println("substring截取字符串"+str0.substring(0,str0.indexOf("a")));//2-1=1

        System.out.println("============================");
        System.out.println("subSequence截取字符串"+str0.subSequence(0,6));

        System.out.println("============================");
        char[] strArray = new char[50];
        str0.getChars(0,6,strArray,6);
        System.out.println("strArray"+strArray);
//        System.out.println("substring截取字符串"+str0.substring(0,100));//越界StringIndexOutOfBoundsException/*/**/*/

        System.out.println("=====================");
        System.out.println("字符串分隔");
        String[] strs=str0.split(",");
        for (String str:strs){
            System.out.println(str);

        }
    }
}
